{-- ======================================================================== -}

module NumParser where

--import Data.Char
--import Text.Read

{-Check if a [Char] is a number.-}
validNumber :: String -> Bool
validNumber str =
    case (reads str) :: [(Integer, String)] of
      [(_, "")] -> True
      _         -> False

toInt :: String -> Integer -> Integer
toInt x y
  | length x > 0 && validNumber x = read x
  | otherwise = y
